function [] = runParamRecovery_displayResults(runId, ctsTime, rep_idxes)

%%% Add paths
addpath('../general_funcs');
addpath('../model_funcs');
addpath('../model_funcs/dim_specific_funcs/dim2');
addpath('../model_funcs/dim_specific_funcs/dim3');
addpath('../consumerAdoptions');
addpath('../providerAdoptions');
addpath('../providerExits');

%%% Get input / output paths
config = getConfig_jointProcess(runId);

% Get config_consumerAdoptions and config_providerAdoptions: necessary input for make_Xdynamic_xxx functions
indivConfigs.consumerAdoptions = getConfig_consumerAdoptions(config.runId_consumerAdoptions);
indivConfigs.providerAdoptions  = getConfig_providerAdoptions(config.runId_providerAdoptions);
indivConfigs.providerExits      = getConfig_providerExits(config.runId_providerExits);

indivRunFolders.providerAdoptions  = config.runFolder_providerAdoptions;
indivRunFolders.providerExits      = config.runFolder_providerExits;
indivRunFolders.consumerAdoptions = config.runFolder_consumerAdoptions;

if ctsTime == 2
	resultsFolder = sprintf('%s/paramRecovery/continuous_time', config.runFolder);
else if ctsTime == 1
	resultsFolder = sprintf('%s/paramRecovery/day_level', config.runFolder);
else
	error('Wrong value of ctsTime.');
end; end;


%%% Load data from the 3 submodels to get parameter names
data = load_data_fullmodel(indivRunFolders);
paramNames.consumerAdoptions = get_param_names_consumerAdoptions(data.consumerAdoptions);
paramNames.providerAdoptions  = get_param_names_providerAdoptions(data.providerAdoptions);
paramNames.providerExits      = get_param_names_providerExits(data.providerExits);

%%%  Load parameter estimates from the 3 submodels => these are going to be the "true parameters" that generate Y in the synthetic data
[truth.params,paramsParts] = load_param_estimates(data, indivRunFolders);

M0_consumerAdoptions = reportSubmodelResults(paramNames.consumerAdoptions, truth.params.consumerAdoptions, -ones(length(truth.params.consumerAdoptions),1), {}, {}, true);
M0_providerAdoptions = reportSubmodelResults(paramNames.providerAdoptions, truth.params.providerAdoptions, -ones(length(truth.params.providerAdoptions),1), {}, {}, true);
M0_providerExits = reportSubmodelResults(paramNames.providerExits, truth.params.providerExits, -ones(length(truth.params.providerExits),1), {}, {}, true);
M0_consumerAdoptions.Properties.VariableNames = {'Truth'};
M0_providerAdoptions.Properties.VariableNames  = {'Truth'};
M0_providerExits.Properties.VariableNames      = {'Truth'};

%%% Load estimation results
NumReps = length(rep_idxes);
estimates.consumerAdoptions = zeros(length(truth.params.consumerAdoptions), NumReps);
estimates.providerAdoptions  = zeros(length(truth.params.providerAdoptions),  NumReps);
estimates.providerExits      = zeros(length(truth.params.providerExits),      NumReps);

for idx = 1:NumReps
	rep_id = rep_idxes(idx);
	% Load consumer adoptions results
	load(sprintf('%s/replication_%03d/consumerAdoptions/results.mat', resultsFolder, rep_id), 'params_hat', 'params_ses');
	estimates.consumerAdoptions(:,idx) = params_hat;
	M1 = reportSubmodelResults(paramNames.consumerAdoptions, params_hat, params_ses, {}, {}, true);
	M1.Properties.VariableNames = {sprintf('Rep%03d', rep_id)};
	if idx == 1
		M_consumerAdoptions = M1;
	else
		M_consumerAdoptions = [M_consumerAdoptions M1];
	end
	clear params_hat params_ses M1;
	
	% Load provider adoptions results
	load(sprintf('%s/replication_%03d/providerAdoptions/results.mat', resultsFolder, rep_id), 'params_hat', 'params_ses');
	estimates.providerAdoptions(:,idx) = params_hat;
	M1 = reportSubmodelResults(paramNames.providerAdoptions, params_hat, params_ses, {}, {}, true);
	M1.Properties.VariableNames = {sprintf('Rep%03d', rep_id)};
	if idx == 1
		M_providerAdoptions = M1;
	else
		M_providerAdoptions = [M_providerAdoptions M1];
	end
	clear params_hat params_ses M1;
	
	% Load provider exits results
	load(sprintf('%s/replication_%03d/providerExits/results.mat', resultsFolder, rep_id), 'params_hat', 'params_ses');
	estimates.providerExits(:,idx) = params_hat;
	M1 = reportSubmodelResults(paramNames.providerExits, params_hat, params_ses, {}, {}, true);
	M1.Properties.VariableNames = {sprintf('Rep%03d', rep_id)};
	if idx == 1
		M_providerExits = M1;
	else
		M_providerExits = [M_providerExits M1];
	end
	clear params_hat params_ses M1;
end

M2_consumerAdoptions = reportSubmodelResults(paramNames.consumerAdoptions, mean(estimates.consumerAdoptions,2), -ones(length(truth.params.consumerAdoptions),1), {}, {}, true);
M2_providerAdoptions  = reportSubmodelResults(paramNames.providerAdoptions,  mean(estimates.providerAdoptions,2),  -ones(length(truth.params.providerAdoptions),1), {}, {}, true);
M2_providerExits      = reportSubmodelResults(paramNames.providerExits,      mean(estimates.providerExits,2),      -ones(length(truth.params.providerExits),1), {}, {}, true);
M2_consumerAdoptions.Properties.VariableNames = {'Mean'};
M2_providerAdoptions.Properties.VariableNames  = {'Mean'};
M2_providerExits.Properties.VariableNames      = {'Mean'};

M3_consumerAdoptions = reportSubmodelResults(paramNames.consumerAdoptions, std(estimates.consumerAdoptions,[],2), -ones(length(truth.params.consumerAdoptions),1), {}, {}, true);
M3_providerAdoptions = reportSubmodelResults(paramNames.providerAdoptions,   std(estimates.providerAdoptions,[],2), -ones(length(truth.params.providerAdoptions),1), {}, {}, true);
M3_providerExits = reportSubmodelResults(paramNames.providerExits,           std(estimates.providerExits,[],2),     -ones(length(truth.params.providerExits),1), {}, {}, true);
M3_consumerAdoptions.Properties.VariableNames = {'StdDev'};
M3_providerAdoptions.Properties.VariableNames  = {'StdDev'};
M3_providerExits.Properties.VariableNames      = {'StdDev'};

M_consumerAdoptions = [M0_consumerAdoptions M2_consumerAdoptions M3_consumerAdoptions M_consumerAdoptions];
M_providerAdoptions  = [M0_providerAdoptions M2_providerAdoptions M3_providerAdoptions M_providerAdoptions];
M_providerExits      = [M0_providerExits M2_providerExits M3_providerExits M_providerExits];

disp(M_consumerAdoptions);
disp(M_providerAdoptions);
disp(M_providerExits);

%%%%%%%%%%% Export into a .txt file that can be easily copy-pasted into a latex document %%%%%%%%%%%
writetable(M_consumerAdoptions, sprintf('%s/consumerAdoptions_results.csv', resultsFolder), 'WriteRowNames', true);
writetable(M_providerAdoptions,  sprintf('%s/providerAdoptions_results.csv',  resultsFolder), 'WriteRowNames', true);
writetable(M_providerExits,      sprintf('%s/providerExits_results.csv',      resultsFolder), 'WriteRowNames', true);
	
end
